home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Think Class Libraries / CommToolbox (modified) / Headers / CConnection.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-30  |  3.6 KB  |  135 lines  |  [TEXT/KAHL]

  1. /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  2.  
  3.     CConnection.h
  4.     
  5.     CommToolbox connection class.
  6.     
  7.     SUPERCLASS = CBureaucrat.
  8.     
  9.     Copyright © 1992-93 Romain Vignes. All rights reserved.
  10.     
  11. ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
  12.  
  13. #ifndef _H_CConnection
  14. #define _H_CConnection
  15.  
  16. #ifdef __USETHREADS__
  17.     #include "CThread.h"                /* Thread Manager */
  18. #endif
  19.  
  20. #include <CBureaucrat.h>                /* Interface for its superclass */
  21.  
  22. #include <Connections.h>                /* Apple includes */
  23.  
  24. /* Connection specific commands */
  25.  
  26. #define cmdConnChoose    2100            /* Connection setup */
  27. #define cmdConnOpen        2101            /* Connection opening */
  28. #define cmdConnClose    2102            /* Connection closing */
  29. #define cmdConnReset    2103            /* Connection reset */
  30. #define cmdConnBreak    2104            /* BREAK signal sending */
  31. #define cmdConnListen    2105            /* Connection listening */
  32.  
  33. #define IOBUFSIZE (1024 * 1)
  34.  
  35. /* Broadcast indications */
  36.  
  37. enum    {
  38.     connOpenInd = 2101,
  39.     connCloseInd
  40. };
  41.  
  42. // callback proc type
  43. #ifndef CommProcPtr
  44. typedef ConnectionCompletionProcPtr CommProcPtr;
  45. #endif
  46.  
  47. typedef ConnectionSearchCallBackProcPtr CommSearchPtr;
  48.  
  49. /* Forward Declarations */
  50.  
  51. class CCluster;
  52.  
  53.  
  54. /* Class definition */
  55.  
  56. class CConnection : public CBureaucrat    {
  57.  
  58. protected:
  59.  
  60.     /* Class Variables */
  61.     
  62.     static CCluster    *cConnList;
  63.  
  64.     /* Instance Variables */
  65.  
  66.     ConnHandle        itsConn;
  67.     Boolean            connOpen;
  68.     
  69.     #ifdef __USETHREADS__
  70.     CThread            *itsIdleThread;
  71.     #endif
  72.     
  73.     virtual OSErr    getStatus(CMBufferSizes *sizes,CMStatFlags *flags);
  74.     
  75. public:
  76.  
  77.     /* Instance Variables */
  78.  
  79.     Boolean            active;
  80.     
  81.     /* Class Methods */
  82.     
  83.     static Boolean        cIsConnectionCmd(long theCmd);
  84.     static OSErr        cCheckToolName(Str31 toolName);
  85.     static void            cConnIdle(void);
  86.     static pascal void     *cOneConnIdle (void *threadParam);
  87.     static void            cInitManager(void);
  88.     static short        cGetCMVersion(void);
  89.     static Boolean        cTestToolEvent(EventRecord *macEvent,WindowPtr theWindow);
  90.  
  91.     /* Instance Methods */
  92.     
  93.     void            IConnection(CBureaucrat *aSupervisor,Str31 toolName,
  94.                         CMRecFlags flags,CMBufferSizes desiredSizes,
  95.                         long refcon, long userData);
  96.     virtual void    Dispose(void);
  97.     virtual void    UpdateMenus(void);
  98.     virtual void    DoCommand(long theCommand);
  99.     virtual    Boolean DoEvent(EventRecord *theEvent,WindowPtr theWindow);
  100.     virtual void    ConnectionChoose(void);
  101.     virtual short    SetConfig(char *theConfig);
  102.     virtual Ptr        GetConfig(void);
  103.     virtual void    OpenConnection(Boolean async,CommProcPtr completor,long timeOut);
  104.     virtual void    ListenConnection(Boolean async,CommProcPtr completor,long timeOut);
  105.     virtual void    CloseConnection(Boolean async,CommProcPtr completor,long timeOut,
  106.                         Boolean now);
  107.     virtual Boolean    IsOpen(void);
  108.     virtual long    DataAvail(void);
  109.     virtual OSErr    DataRead(Ptr inBuffer,long *buffSize,Boolean async,
  110.                         CommProcPtr completor,long timeOut,CMFlags *flags,CMChannel channel = cmData);
  111.     virtual void    DoIdle(void);
  112.     virtual OSErr    DataWrite(Ptr inBuffer,long *buffSize,Boolean async,
  113.                         CommProcPtr completor,long timeOut,CMFlags flags);
  114.     virtual void    Activate(void);
  115.     virtual void    Deactivate(void);
  116.     virtual void    Reset(void);
  117.     virtual void    SendBreak(void);
  118.     virtual OSErr    GetEnvirons(ConnEnvironRecPtr theEnvirons);
  119.     virtual void    GetToolName(Str31 toolName);
  120.     
  121.     virtual long    AddSearch(Str255 theString, CMSearchFlags flags, CommSearchPtr callBack); 
  122.     virtual void    RemoveSearch(long refNum); 
  123.     virtual void    ClearSearch(void);
  124.         
  125.     virtual ConnHandle GetConnHandle (void);
  126.     
  127.     /* default call-back procs. */
  128.     static pascal void DefAutoRecCallback(ConnHandle theConn, Ptr data, long refNum);
  129.  
  130. };
  131.  
  132. #endif
  133.  
  134. /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
  135.